<!doctype html>
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="shortcut icon" href="/favicon.ico"/>
    <title>智能售卡系统</title>
    <link rel="stylesheet" href="../../..//public/layui/css/layui.css">
    <script src="../../..//public/layui/layui.js"></script>
    <script src="../../..//public/jquery/jquery.min.js"></script>
    <style>
        .fixed-top {
            position: fixed;
            top: 0;
            left: 0;
            right: 0;
            line-height: 70px;
            z-index: 1000; /* 确保导航栏在页面其他内容的上方 */
            background-color: #fff; /* 根据需要设置背景颜色 */
            box-shadow: 0 2px 4px rgba(0,0,0,0.1); /* 添加一个简单的阴影效果 */
        }
        .nav-right {
            display: flex;
            align-items: center;
            list-style: none; /* Remove bullet points */
            margin: 0;
            padding-right: 5px;
            line-height: 70px;
            justify-content: right;
        }
    </style>
</head>
<body>
<div class="layui-row fixed-top">
    <div class="layui-col-xs8 layui-col-sm8 layui-col-md10">
        <a href=""><img src="<?= htmlspecialchars($icon) ?>" width="50px" height="50px" style="margin-left: 10px"/><span style="margin-left: 10px"><?=htmlspecialchars($name)?></span></a>
        <a href="/index" style="margin-left: 5px">首页</a>
        <!--        <a href="/about" style="margin-left: 5px">关于</a>-->
        <a href="/help" style="margin-left: 5px">手册</a>
    </div>
    <div class="layui-col-xs4 layui-col-sm4 layui-col-md2 nav-right">
        <li class="layui-nav-item" id="login-item" style="margin-right: 4px"><a href="/login" id="login">登录</a></li>
        <li class="layui-nav-item" id="logout-item"><a href="javascript:void(0);" id="logout"><span>退出</span></a></li>
    </div>
</div>
<div style="margin-left: 40px;margin-right: 40px;margin-top: 90px">
    <blockquote class="layui-elem-quote">
        使用基础手册
    </blockquote>
</div>

<div style="margin-left: 50px;margin-right: 50px;">
    <h1><span style="color: red">注意</span></h1>
    <a href="http://www.eatandshow.com//app/admin/upload/files/20240704/668654290841.apk"><span style="color: #0d6efd">最新安装包下载</span></a>
    <br>
    <p>受限于部分原因，手册请跳转个人blog详细查看</p>
    <h1><a href="https://blog.csdn.net/u014449096/article/details/140021008?spm=1001.2014.3001.5501"><span style="color: red">详细演示说明文档，内含视频演示效果</span></a></h1>
    <br>
    <br>
    <p>
        说明：
        自行购买服务器搭建网站并自行部署，商品自行添加，收款码自行添加；
        所有购买操作金额直接到个人账户，其他任何人不参与收款；
        个人手机收取金额后刷新服务器订单，
        所涉及金额全程仅在自己服务器与自己手机账户之间流转，避免跑路风险；
        注意 该项目仅允许用于正规途径，禁止任何违法违规场景使用，开发人员不参与任何项目运营
    </p>
    <br>
    <br>
    <a href="https://gitee.com/qobn/sale-system.git"><span style="color: red;font-size: 20px">服务器代码地址</span></a>
    <br>
    <img src="./../..//public/img/pay_result_back.png" alt="支付回调展示">
    <br>
    <br>
    <p>基于<a href="https://www.workerman.net" target="_blank">webman+workerman</a>开发</p>

    <h4>禁用函数检查</h4>
    <p>使用这个脚本检查是否有禁用函数。命令行运行<code>curl -Ss https://www.workerman.net/check | php</code> 如果有提示<code>Function 函数名 may be disabled. Please check disable_functions in php.ini</code>说明workerman依赖的函数被禁用，需要在php.ini中解除禁用才能正常使用workerman。</p>
    <p>解除禁用参考如下两种方法任选其一即可。</p>

    <h5>方式一</h5>
    <p>脚本解除</p>
    <blockquote>执行脚本 <code>curl -Ss https://www.workerman.net/fix | php</code> 以解除禁用</blockquote>

    <h5>方法二：手动解除</h5>
    <h6>步骤如下：</h6>
    <ol>
        <li>运行<code>php --ini</code> 找到php cli所使用的php.ini文件位置</li>
        <li>打开php.ini，找到disable_functions一项解除对应函数的禁用
            <ul>
                <li>依赖的函数 使用workerman需要解除以下函数的禁用
                    <pre>
                            stream_socket_server
                            stream_socket_client
                            pcntl_signal_dispatch
                            pcntl_signal
                            pcntl_alarm
                            pcntl_fork
                            posix_getuid
                            posix_getpwuid
                            posix_kill
                            posix_setsid
                            posix_getpid
                            posix_getpwnam
                            posix_getgrnam
                            posix_getgid
                            posix_setgid
                            posix_initgroups
                            posix_setuid
                            posix_isatty
                        </pre>
                </li>
            </ul>
        </li>
    </ol>

    <h6>部署</h6>
    <p>建议选择宝塔进行部署</p>

    <h5>1、环境</h5>
    <p>注意环境尽量保持一致</p>
    <img src="./../..//public/img/img.png" alt="环境配置"/>

    <h5>2、php禁用函数手动解除</h5>
    <img src="./../..//public/img/php_setting.png" alt="禁用函数解除">

    <h5>3、手动解除的话需要自行删除 自动删除的方式不一定能删除完整</h5>
    <img src="./../..//public/img/php_setting_info.png" alt="手动删除">

    <h4>宝塔如何添加网站 - 代码上传请自行处理</h4>
    <img src="./../..//public/img/baota_add_project.png" alt="宝塔添加网站">
    <img src="./../..//public/img/project_how_to_set.png" alt="代码上传">
    <img src="./../..//public/img/server_local_detail.png" alt="上传完成">
    <img src="./../..//public/img/create_project_over_setting.png" alt="Nginx配置">
    <img src="./../..//public/img/add_a_reverse_proxy.png" alt="Nginx配置完成">
    <img src="./../..//public/img/proxy_content.png" alt="配置完成">

    <h5>Nginx 配置</h5>
    <p>完整配置</p>
    <pre>
            user  www www;
            worker_processes auto;
            error_log  /www/wwwlogs/nginx_error.log  crit;
            pid        /www/server/nginx/logs/nginx.pid;
            worker_rlimit_nofile 51200;

            stream {
                log_format tcp_format '$time_local|$remote_addr|$protocol|$status|$bytes_sent|$bytes_received|$session_time|$upstream_addr|$upstream_bytes_sent|$upstream_bytes_received|$upstream_connect_time';
                access_log /www/wwwlogs/tcp-access.log tcp_format;
                error_log /www/wwwlogs/tcp-error.log;
                include /www/server/panel/vhost/nginx/tcp/*.conf;
            }

            events {
                use epoll;
                worker_connections 51200;
                multi_accept on;
            }

            http {
                include       mime.types;
                #include luawaf.conf;
                include proxy.conf;
                lua_package_path "/www/server/nginx/lib/lua/?.lua;;";

                default_type  application/octet-stream;

                server_names_hash_bucket_size 512;
                client_header_buffer_size 32k;
                large_client_header_buffers 4 32k;
                client_max_body_size 50m;

                sendfile   on;
                tcp_nopush on;

                keepalive_timeout 60;

                tcp_nodelay on;

                fastcgi_connect_timeout 300;
                fastcgi_send_timeout 300;
                fastcgi_read_timeout 300;
                fastcgi_buffer_size 64k;
                fastcgi_buffers 4 64k;
                fastcgi_busy_buffers_size 128k;
                fastcgi_temp_file_write_size 256k;
                fastcgi_intercept_errors on;

                gzip on;
                gzip_min_length  1k;
                gzip_buffers     4 16k;
                gzip_http_version 1.1;
                gzip_comp_level 2;
                gzip_types     text/plain application/javascript application/x-javascript text/javascript text/css application/xml;
                gzip_vary on;
                gzip_proxied   expired no-cache no-store private auth;
                gzip_disable   "MSIE [1-6]\.";

                limit_conn_zone $binary_remote_addr zone=perip:10m;
                limit_conn_zone $server_name zone=perserver:10m;

                server_tokens off;
                access_log off;

                upstream webman {
                    server 127.0.0.1:8787;
                    keepalive 10240;
                }
                upstream websocket_backend {
                    server 127.0.0.1:7272;
                }

                server {
                    listen 888;
                    server_name phpmyadmin;
                    index index.html index.htm index.php;
                    root  /www/server/phpmyadmin;

                    location ~ /tmp/ {
                        return 403;
                    }

                    #error_page   404   /404.html;
                    include enable-php.conf;

                    location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$ {
                        expires 30d;
                    }

                    location ~ .*\.(js|css)?$ {
                        expires 12h;
                    }

                    location ~ /\\.
                    {
                        deny all;
                    }

                    access_log  /www/wwwlogs/access.log;
                }

                map $http_upgrade $connection_upgrade {
                    default upgrade;
                    '' close;
                }

                server {
                    listen 80;
                    server_name www.baidu.com;
                    access_log off;
                    # root /www/wwwroot/SaleSystem;

                    location ^~ / {
                        proxy_set_header X-Real-IP $remote_addr;
                        proxy_set_header Host $http_host;
                        proxy_set_header X-Forwarded-Proto $scheme;
                        proxy_http_version 1.1;
                        proxy_set_header Connection "";
                        if (!-f $request_filename){
                            proxy_pass http://webman;
                        }
                    }
                    location /websocket {
                        proxy_pass http://websocket_backend;
                        proxy_http_version 1.1;
                        proxy_set_header Upgrade $http_upgrade;
                        proxy_set_header Connection $connection_upgrade;
                    }
                }
                include /www/server/panel/vhost/nginx/*.conf;
            }
        </pre>

    <p>这里需要特别注意-支付结果回调靠这个完整-配置完成后自行测试几单验证结果</p>
    <pre>
            location /websocket {
                proxy_pass http://websocket_backend;
                proxy_http_version 1.1;
                proxy_set_header Upgrade $http_upgrade;
                proxy_set_header Connection $connection_upgrade;
            }
        </pre>

    <h5>上述操作完成后 如何启动项目</h5>
    <ol>
        <li>进入系统根目录 以我的目录为例：<code>cd www/wwwroot/SaleSystem/</code></li>
        <li>执行指令 <code>php start.php start -d</code> 以守护方式启动</li>
        <li>启动结果</li>
        <img src="../../..//public/img/start_result.png" alt="启动结果">
    </ol>

    <h5>如何安装 - 若无法播放 视频在项目根目录下 ztodu 目录中 system_install.mp4 自行播放 --- 太大了 无法提交 请到博客中观看</h5>


    <h5>搭配收款监控到账 app</h5>
    <p>找一部用不到的手机,安装到账监控apk后，授予最高权限，其中通知栏，必须、系统常亮等权限最好也开启，然后插着电放那儿完事。（尽可能给与更高权限，该app仅仅涉及监控到账信息并与服务器交互，不涉及其他功能，请放心食用）</p>
    <ol>
        <li>运行安装</li>
        <li>授权app打开通知栏等权限</li>
        <li>手机自身设置屏幕常亮不息屏</li>
        <li>联系管理员将设备添加管理平台</li>
    </ol>
</div>
<script>
    layui.$(document).ready(function() {
        let username = localStorage.getItem('username');
        let loginItem = layui.$('#login-item');
        let logoutItem = layui.$('#logout-item');
        let loginButton = layui.$('#login');
        let logoutButton = layui.$('#logout');

        if (username) {
            // 用户已登录，显示用户名，隐藏登录按钮，显示退出按钮
            loginButton.text(username);
            loginButton.attr('href', 'javascript:void(0);'); // 禁止跳转登录页面
            logoutItem.show();
            loginItem.show();
        } else {
            // 用户未登录，显示登录按钮，隐藏退出按钮
            loginItem.show();
            logoutItem.hide();
        }

        layui.$('#logout').on('click', function() {
            //console.log('点击退出按钮');
            layui.$.ajax({
                url:'/app/admin/user/logout',
                type: "POST",
                data: {user_id:localStorage.getItem('user_id')},
                success:function (res) {
                    layer.msg('退出成功')
                    localStorage.removeItem('username');
                    localStorage.removeItem('token');
                    localStorage.removeItem('user_id');
                    setTimeout(function () {
                        location.reload(); // 刷新页面以更新按钮显示
                    },1500)
                },error:function (res){

                }
            })

        });
    });
</script>
</body>
</html>
